package com.zretc.controller;

import com.github.pagehelper.PageInfo;
import com.zretc.entity.Vip;
import com.zretc.service.BackVipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;



@Controller
@RequestMapping("/back")
public class BackVipController {

    @Autowired
    private BackVipService backVipeService;


    @GetMapping("vipInfoManagement")
    @ResponseBody
    public PageInfo<Vip> getVipInfo(String page,String limit){

        PageInfo<Vip> vipInfo = backVipeService.getVipInfo(page,limit);

        return vipInfo;

    }


   @RequestMapping("vipInfoManagement")
    @ResponseBody
    public PageInfo<Vip> findByVipId(String vipId,String page,String limit){

        PageInfo<Vip>vipInfoByVipId = backVipeService.findByVipId(vipId,page,limit);

        return vipInfoByVipId;

    }


    @PostMapping("vipInfoManagement")
    @ResponseBody
    public int addVip(Vip vip){

        int addVip = backVipeService.addVip(vip);

        return addVip;

    }


    @DeleteMapping("vipInfoManagementDelete/{vipId}")
    @ResponseBody
    public int deleteVipInfoByVipId(@PathVariable("vipId") String vipId){

        int deleteVipInfoByVipId = backVipeService.deleteVipInfoByVipId(vipId);

        return deleteVipInfoByVipId;
    }


    @PutMapping("vipInfoManagement")
    @ResponseBody
    public int updateVipInfoByAccountId(Vip vip){

        int updateVipInfoByAccountId = backVipeService.updateVipInfoByAccountId(vip);

        return updateVipInfoByAccountId;
    }
}
